from setuptools import find_packages, setup
from glob import glob
import os

package_name = 'sls_launch_sim'

# Helper function to collect all files recursively
def get_all_files(source_dir, target_base):
    data_files = []
    for root, dirs, files in os.walk(source_dir):
        target_dir = os.path.join(target_base, os.path.relpath(root, source_dir))
        file_paths = [os.path.join(root, f) for f in files]
        if file_paths:
            data_files.append((target_dir, file_paths))
    return data_files

setup(
    name=package_name,
    version='0.0.0',
    packages=find_packages(exclude=['test']),
    data_files=[
        ('share/ament_index/resource_index/packages',
            ['resource/' + package_name]),
        ('share/' + package_name, ['package.xml']),
        (os.path.join('share', package_name, 'launch'), glob('sls_launch_sim/*')),
        (os.path.join('share', package_name, 'config'), glob('config/*')),
        # Recursively include all files under models
        *get_all_files('models', os.path.join('share', package_name, 'models')),
        (os.path.join('share', package_name, 'gzstart'), glob('gzstart/*')),
        (os.path.join('share', package_name, 'worlds'), glob('worlds/*')), 
        (os.path.join('share',package_name, 'depends'), glob('ugv_sim_depends/*'))               
    ],
    install_requires=['setuptools'],
    zip_safe=True,
    maintainer='hpdadi',
    maintainer_email='hph123t@qq.com',
    description='TODO: Package description',
    license='TODO: License declaration',
    tests_require=['pytest'],
    entry_points={
        'console_scripts': [
            'position_publisher = ugv_sim_depends.position_publisher:main',
            'relay_node = ugv_sim_depends.relay_node:main',
            'chassis_cmd_node = ugv_sim_depends.chassis_cmd_node:main',
            'motor_state_bridge = ugv_sim_depends.motor_state_bridge:main',
            'steering_bridge = ugv_sim_depends.steering_bridge:main',
        ],
    },
)
